import pygame
import data
from globalconstants import *

class SoundMachine(object):
    
    @staticmethod
    def StopAllSounds():
        SoundMachine.Sound_Round_Firemen.stop()
        SoundMachine.Sound_Round_Valve.stop()
        SoundMachine.Sound_Round_WaterFromOcean.stop()
        SoundMachine.Sound_Round_ProtectionWear.stop()
        SoundMachine.Sound_Round_RestoreElectricity.stop()
        SoundMachine.Sound_Round_SpecialCable.stop()
        SoundMachine.Sound_Round_SyntheticResin.stop()
        SoundMachine.Sound_Round_SodiumSilicate.stop()
        SoundMachine.Sound_Round_Helicopter.stop()
        
        SoundMachine.Sound_Catastropy_LeakingGas.stop()
        SoundMachine.Sound_Catastropy_PartialMeltdown.stop()
        SoundMachine.Sound_Catastropy_OuterExplosion.stop()
        SoundMachine.Sound_Catastropy_InnerExplosion.stop()
        SoundMachine.Sound_Catastropy_FullMeltdown.stop()
        SoundMachine.Sound_Catastropy_Facture.stop()
    
        SoundMachine.Sound_Initial_Sound.stop()
    
    @staticmethod
    def LoadAllSounds():

        SoundMachine.Sound_Initial_Sound = pygame.mixer.Sound(data.filepath("Audio/53765__digifishmusic__Tectonic_1.ogg"))

                
        SoundMachine.Sound_Catastropy_LeakingGas = pygame.mixer.Sound(data.filepath("Audio/Katastrophen/66248__Robinhood76__00773_leaking_gas_1.ogg"))
        SoundMachine.Sound_Catastropy_PartialMeltdown = pygame.mixer.Sound(data.filepath("Audio/Katastrophen/82390__Benboncan__Retreating_Earthworms.ogg"))
        SoundMachine.Sound_Catastropy_OuterExplosion = pygame.mixer.Sound(data.filepath("Audio/Katastrophen/95078__sandyrb__THE_CRASH2.ogg"))
        
        SoundMachine.Sound_Catastropy_InnerExplosion = pygame.mixer.Sound(data.filepath("Audio/Katastrophen/93741__Omar_Alvarado__Explosion.ogg"))
        SoundMachine.Sound_Catastropy_FullMeltdown = pygame.mixer.Sound(data.filepath("Audio/Katastrophen/98858__Timbre__Simulated_underground_lava_3.ogg"))
        SoundMachine.Sound_Catastropy_Facture = pygame.mixer.Sound(data.filepath("Audio/Katastrophen/99960__CGEffex__Large_Crash.ogg"))
        
        SoundMachine.Sound_Round_Firemen = pygame.mixer.Sound(data.filepath("Audio/Rundensounds/22374__iktinus__stream_II_by_iktinus.ogg"))
        SoundMachine.Sound_Round_Valve = pygame.mixer.Sound(data.filepath("Audio/Rundensounds/31380__FreqMan__squeaky_valve.ogg"))
        SoundMachine.Sound_Round_WaterFromOcean = pygame.mixer.Sound(data.filepath("Audio/Rundensounds/31762__Slanesh__Ocean.ogg"))
        
        SoundMachine.Sound_Round_ProtectionWear = pygame.mixer.Sound(data.filepath("Audio/Rundensounds/51176__zipper2.ogg"))
        SoundMachine.Sound_Round_RestoreElectricity = pygame.mixer.Sound(data.filepath("Audio/Rundensounds/52597__chipfork__Spark_02.ogg"))        
        SoundMachine.Sound_Round_SpecialCable = pygame.mixer.Sound(data.filepath("Audio/Rundensounds/53679__lonemonk__Switch_and_Ballast_1.ogg"))
        
        SoundMachine.Sound_Round_SyntheticResin = pygame.mixer.Sound(data.filepath("Audio/Rundensounds/56707__ReWired__69_SPRWA.ogg"))
        SoundMachine.Sound_Round_SodiumSilicate = pygame.mixer.Sound(data.filepath("Audio/Rundensounds/65412__KGJones__Blubs.ogg"))    
        SoundMachine.Sound_Round_Helicopter = pygame.mixer.Sound(data.filepath("Audio/Rundensounds/66643__Benboncan__Chinook_High.ogg"))
    
    @staticmethod
    def PlayInitialSound():
        SoundMachine.Sound_Initial_Sound.play()
    
    @staticmethod    
    def PlayRoundSound(id):        
        SoundMachine.Sound_Round_Firemen.stop()
        SoundMachine.Sound_Round_Valve.stop()
        SoundMachine.Sound_Round_WaterFromOcean.stop()
        SoundMachine.Sound_Round_ProtectionWear.stop()
        SoundMachine.Sound_Round_RestoreElectricity.stop()
        SoundMachine.Sound_Round_SpecialCable.stop()
        SoundMachine.Sound_Round_SyntheticResin.stop()
        SoundMachine.Sound_Round_SodiumSilicate.stop()
        SoundMachine.Sound_Round_Helicopter.stop()
        
        #pygame.mixer.stop()
        #SoundMachine.Sound_Catastropy_LeakingGas.play()
        if id == SOUND_ROUND_FIREMEN:
            SoundMachine.Sound_Round_Firemen.play()
        elif id == SOUND_ROUND_VALVE:
            SoundMachine.Sound_Round_Valve.play()
        elif id == SOUND_ROUND_WATER_FROM_OCEAN:
            SoundMachine.Sound_Round_WaterFromOcean.play()
        elif id == SOUND_ROUND_PROTECTION_WEAR:
            SoundMachine.Sound_Round_ProtectionWear.play()
        elif id == SOUND_ROUND_RESTORE_ELECTRICITY:
            SoundMachine.Sound_Round_RestoreElectricity.play()
        elif id == SOUND_ROUND_SPECIAL_CABLE:
            SoundMachine.Sound_Round_SpecialCable.play()
        elif id == SOUND_ROUND_SYNTHETIC_RESIN:
            SoundMachine.Sound_Round_SyntheticResin.play()
        elif id == SOUND_ROUND_SODIUM_SILICATE:
            SoundMachine.Sound_Round_SodiumSilicate.play()
        elif id == SOUND_ROUND_HELICOPTER:
            SoundMachine.Sound_Round_Helicopter.play()
            
    @staticmethod    
    def PlayAccidentSound(id):        
        #pygame.mixer.stop()
        #SoundMachine.Sound_Catastropy_LeakingGas.play()
        if id == SOUND_ACCIDENT_LEAKING_GAS:
            SoundMachine.Sound_Catastropy_LeakingGas.play()
        elif id == SOUND_ACCIDENT_PARTIAL_MELTDOWN:
            SoundMachine.Sound_Catastropy_PartialMeltdown.play()
        elif id == SOUND_ACCIDENT_OUTER_EXPLOSION:
            SoundMachine.Sound_Catastropy_OuterExplosion.play()
        elif id == SOUND_ACCIDENT_INNER_EXPLOSION:
            SoundMachine.Sound_Catastropy_InnerExplosion.play()
        elif id == SOUND_ACCIDENT_FRATURE:
            SoundMachine.Sound_Catastropy_Facture.play()
        elif id == SOUND_ACCIDENT_FULL_MELTDOWN:
            SoundMachine.Sound_Catastropy_FullMeltdown.play()            
    